package com.qubuyer.core.utils

import android.os.Process
import android.text.TextUtils
import java.io.BufferedReader
import java.io.FileReader
import java.io.IOException

/**
 * Author: linwg
 * Time: 2021/2/2 0002
 * Description:
 */
class AppUtil {
    companion object{
        fun getProcessName():String?{
            var reader: BufferedReader? = null
            try {
                reader = BufferedReader(FileReader("/proc/${Process.myPid()}/cmdline"))
                var processName: String = reader.readLine()
                if (!TextUtils.isEmpty(processName)) {
                    processName = processName.trim { it <= ' ' }
                }
                return processName
            } catch (throwable: Throwable) {
                throwable.printStackTrace()
            } finally {
                try {
                    reader?.close()
                } catch (exception: IOException) {
                    exception.printStackTrace()
                }
            }
            return null
        }
    }
}